#include "SceneManager.h"
SceneManager* SceneManager::_instance = NULL; // initialization


SceneManager::SceneManager() {
	_rootSceneNode = new SceneNode(NULL);
}

SceneManager::~SceneManager() {
}

SceneManager * SceneManager::Instance() {
	return _instance;
}

void SceneManager::destroy() {
	delete _instance;
	_instance = NULL;
}

void SceneManager::create() {
	if (_instance == NULL) {
		_instance = new SceneManager();	
	}
}
	
Camera * SceneManager::getCamara() const {
	return (Camera *) _rootSceneNode->getEntity("camera");
}

void SceneManager::setCamera(Camera * c) {
	_rootSceneNode->addEntity(c);
}

SceneNode * SceneManager::getRootSceneNode() const {
	return _rootSceneNode;
}

GameEntity * SceneManager::getEntity(const std::string& name) const {
	return _rootSceneNode->getEntity(name);	//when the getEntity on rootSceneNode is called 
											//it finds the entity from the current node
}

void SceneManager::updateScene() {
	_rootSceneNode->updateSceneNode();		//when the updateSceneNode on rootSceneNode is called 
											//it updates the scene from the current node
}
void SceneManager::renderScene() {
	//_rootSceneNode->enterRenderingSceneNode();
	_rootSceneNode->renderSceneNode();		//when the renderSceneNode on rootSceneNode is called 
											//it renders the scene from the current node
	//_rootSceneNode->exitRenderingSceneNode();
}
void SceneManager::clearScene() {
	_rootSceneNode->deleteAllChilderAndEntitiesSceneNode();		//Question: Not sure if to use this or deleteAllChildrenSceneNodes()
}
